package com.ruoyi.web.controller.qynhgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qynygl.domain.TbQynyglYqsyl;
import com.ruoyi.qynygl.service.ITbQynyglYqsylService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 园区使用量Controller
 * 
 * @author ruoyi
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/qynygl/yqsyl")
public class TbQynyglYqsylController extends BaseController
{
    @Autowired
    private ITbQynyglYqsylService tbQynyglYqsylService;

    /**
     * 查询园区使用量列表
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbQynyglYqsyl tbQynyglYqsyl)
    {
        startPage();
        List<TbQynyglYqsyl> list = tbQynyglYqsylService.selectTbQynyglYqsylList(tbQynyglYqsyl);
        return getDataTable(list);
    }

    /**
     * 导出园区使用量列表
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:export')")
    @Log(title = "园区使用量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbQynyglYqsyl tbQynyglYqsyl)
    {
        List<TbQynyglYqsyl> list = tbQynyglYqsylService.selectTbQynyglYqsylList(tbQynyglYqsyl);
        ExcelUtil<TbQynyglYqsyl> util = new ExcelUtil<TbQynyglYqsyl>(TbQynyglYqsyl.class);
        util.exportExcel(response, list, "园区使用量数据");
    }

    /**
     * 获取园区使用量详细信息
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbQynyglYqsylService.selectTbQynyglYqsylById(id));
    }

    /**
     * 新增园区使用量
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:add')")
    @Log(title = "园区使用量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbQynyglYqsyl tbQynyglYqsyl)
    {
        return toAjax(tbQynyglYqsylService.insertTbQynyglYqsyl(tbQynyglYqsyl));
    }

    /**
     * 修改园区使用量
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:edit')")
    @Log(title = "园区使用量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbQynyglYqsyl tbQynyglYqsyl)
    {
        return toAjax(tbQynyglYqsylService.updateTbQynyglYqsyl(tbQynyglYqsyl));
    }

    /**
     * 删除园区使用量
     */
    @PreAuthorize("@ss.hasPermi('qynygl:yqsyl:remove')")
    @Log(title = "园区使用量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbQynyglYqsylService.deleteTbQynyglYqsylByIds(ids));
    }
}
